<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="####1. Maven概念模型">
<meta name="keywords" content="Android、iOS、Web、React Native">
<meta property="og:type" content="article">
<meta property="og:title" content="Maven入门">
<meta property="og:url" content="http://yoursite.com/blog/2018/08/06/Maven/Maven入门/index.html">
<meta property="og:site_name" content="凌浩雨_博客">
<meta property="og:description" content="####1. Maven概念模型">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-c97d11ce64af564d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-d919cfa9402b0b40?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-13706354e8946924.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-55cbf08518f5c962.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-8fcc1a1bdb70d915.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-ad714ec5a82210f1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-167c0f49e37c7a7e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-9b1eb3e10ee08ed4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-24f5c64838abcbc7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-ab657912fabe23a9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-2d450c4b3a0f2a11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-8a773f1b2186bb11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-eaf0e9a3f96a8320.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-cdd49781a5d79e5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-a8acd19bfa85dbea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-6d9891840f2239bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-5a5efe93b6aaf592.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-6b4b9177ba6366c6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-5e132867e47beb1f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-90e40a33c495d6e0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-56016aa23acfdcb4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-2beb14f0ebc82bc6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-f4b135ef07df8617.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-fab394448fd754ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-08-06T10:36:58.007Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Maven入门">
<meta name="twitter:description" content="####1. Maven概念模型">
<meta name="twitter:image" content="https://upload-images.jianshu.io/upload_images/3110861-c97d11ce64af564d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/blog/2018/08/06/Maven/Maven入门/"/>





  <title>Maven入门 | 凌浩雨_博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">凌浩雨_博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/blog/blog/2018/08/06/Maven/Maven入门/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="凌浩雨">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="凌浩雨_博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Maven入门</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-06T18:01:39+08:00">
                2018-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>####1. <a href="http://maven.apache.org/" target="_blank" rel="noopener">Maven</a>概念模型<br><img src="https://upload-images.jianshu.io/upload_images/3110861-c97d11ce64af564d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图1.png"><br><a id="more"></a></p>
<ul>
<li>项目对象模型(Project Object Mobel)<br>  通过pom.xml定义项目的坐标、项目依赖、项目信息、插件目标等。每个maven工程中都有一个pom.xml文件(核心配置文件)，该文件里面定义了工程所依赖的jar包、本工程的坐标、打包运行方式等。</li>
<li><p>依赖管理系统(Dependency Management System)<br>  maven的基础核心，通过定义项目所依赖组件的坐标由maven进行依赖管理。也即maven通过坐标对项目工程所依赖的jar包进行统一规范的管理。<br>  比如：项目依赖Struts2.3.24，通过在pom.xml中定义依赖即可将Struts2的jar包自动加入到工程中，pom.xml中定义依赖如下：</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groundId&gt;org.apache.struts&lt;/groundId&gt;</span><br><span class="line">    &lt;artifactId&gt;struts2-core&lt;/artifactId&gt;</span><br><span class="line">    &lt;version&gt;2.3.24&lt;/version&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></table></figure>
</li>
<li><p>一个项目生命周期(Project Lifecycle)<br>  一个软件开发人员每天都在完成项目的生命周期：清理、编译、测试、部署，有的手工完成，有的通过Ant(也是一个项目构建工具)脚本自动完成，maven将项目的生命周期抽象统一为：清理、初始化、编译、测试、报告、打包、部署、站点生成等。<br>  <img src="http://upload-images.jianshu.io/upload_images/3110861-d919cfa9402b0b40?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图2.png"><br>  maven就是要保证一致的项目构建流程，通过执行一些简单命令即可实现上边生命周期的各个过程。</p>
</li>
<li>一组标准集合<br>  maven将整个项目管理过程定义一组标准，比如：通过maven构建工程有标准的目录结构，有标准的生命周期阶段、依赖管理有标准的坐标定义等。<br>  我在这儿还是强调一遍：maven工程有自己标准的工程目录结构、有标准的坐标定义。</li>
<li>插件(plugin)目标(goal)<br>  maven管理项目生命周期过程都是基于插件完成的。</li>
</ul>
<p>####2. maven的仓库<br>maven工作需要配置仓库，本地的项目A、项目B等通过maven从远程仓库(可以理解为互联网上的仓库)下载jar包并保存在本地仓库，本地仓库就是本地文件夹，当第二次需要此jar包时则不再从远程仓库下载，因为本地仓库已经存在了。可以将本地仓库理解为缓存，有了本地仓库就不用每次从远程仓库下载了。<br>下面描述了maven中仓库的类型：<br><img src="https://upload-images.jianshu.io/upload_images/3110861-13706354e8946924.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图3.png"></p>
<ul>
<li>本地仓库：用来存储从远程仓库或中央仓库下载的插件和jar包，项目使用一些插件或jar包，优先从本地仓库查找。 </li>
<li>远程仓库：如果本地需要插件或者jar包，本地仓库没有，默认从远程仓库下载。 </li>
<li>中央仓库：在maven环境内部内置一个远程仓库地址：<code>http://repo1.maven.org/maven2</code>，它是中央仓库(即特殊的远程仓库)，服务于整个互联网，它是由maven团队自己维护的，里面由大量的常用类库，并包含了世界上大部分流行的开源项目构件。 </li>
</ul>
<p>####3. 安装</p>
<p>######1). 下载和安装–<a href="http://maven.apache.org/download.cgi" target="_blank" rel="noopener">下载地址</a><br><img src="https://upload-images.jianshu.io/upload_images/3110861-55cbf08518f5c962.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图4.png"></p>
<ul>
<li>bin目录：mvn.bat(以run方式运行项目)、mvnDebug.bat(以debug方式运行项目)</li>
<li>boot目录：maven运行需要的类加载器</li>
<li>conf目录：settings.xml，整个maven工具的核心配置文件</li>
<li>lib目录：maven运行依赖的jar包<br>######2). 配置环境变量<br>I. 新建环境变量<br><img src="https://upload-images.jianshu.io/upload_images/3110861-8fcc1a1bdb70d915.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图5.png"><br>II. 将<code>%MAVEN_HOME%\bin</code>添加到path环境变量中<br><img src="https://upload-images.jianshu.io/upload_images/3110861-ad714ec5a82210f1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图6.png"><br>III. 测试<br>在命令提示符中输入命令–<code>mvn -v</code><br><img src="https://upload-images.jianshu.io/upload_images/3110861-167c0f49e37c7a7e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图7.png"></li>
</ul>
<p>######3). 本地仓库配置<br>本地仓库是用来存放联网下载的maven插件和jar包，maven本地仓库有的jar包将不再从互联网下载，所以本地仓库就相当于一个缓存。<br>在maven的安装目录中的conf目录下有一个settings.xml文件，在这个文件中可配置本地仓库<br><img src="https://upload-images.jianshu.io/upload_images/3110861-9b1eb3e10ee08ed4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图8.png"></p>
<p>如果本地仓库不配置(那么就会从互联网上下载jar包，而且下载速度贼慢)，那么默认的本地仓库的位置就是${user.home}/.m2/repository目录，${user.home}表示windows用户目录，在win7系统下如下：<br><img src="https://upload-images.jianshu.io/upload_images/3110861-24f5c64838abcbc7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图9.png"></p>
<ul>
<li>全局settings配置文件：就是maven的安装目录中的conf目录下的settings.xml文件。该文件里面的所有配置可应用于所有项目。</li>
<li>用户settings配置文件：在${user.home}/.m2/repository目录下。如果某些用户需要对maven特殊设置，用户可以自定义settings文件<br>######4). eclipse配置maven安装程序<br>高版本的eclipse默认已经集成了maven的插件，但其实还内置了maven程序，Window-&gt;Preferences,搜索maven如下：<br><img src="https://upload-images.jianshu.io/upload_images/3110861-ab657912fabe23a9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图10.png"><br><strong>注意：我们一般不用内置的maven程序，原因是为了在项目中统一maven版本</strong><br>######5). 选择指定的maven程序<br>点击Add…-&gt;&gt;然后选择自己电脑中的maven程序-&gt;&gt;点击Finish。<br><img src="https://upload-images.jianshu.io/upload_images/3110861-2d450c4b3a0f2a11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图11.png"><br>然后勾选新增的一项。<br><img src="https://upload-images.jianshu.io/upload_images/3110861-8a773f1b2186bb11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图12.png"></li>
</ul>
<p>######6). 指定User Settings<br>点击User Settings-&gt;点击Browse…选择settings.xml文件-&gt;点击Update Settings，在Local Repository一项会自动填充仓库位置-&gt;点击Apply-&gt;OK。<br><img src="https://upload-images.jianshu.io/upload_images/3110861-eaf0e9a3f96a8320.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图13.png"></p>
<p>######7). Eclipse浏览本地仓库<br>Window-&gt;Show View-&gt;Other-&gt;Maven-&gt;Maven Repositories.<br><img src="https://upload-images.jianshu.io/upload_images/3110861-cdd49781a5d79e5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图14.png"></p>
<p>####4. 测试项目</p>
<p>######1). 新建项目<br>I. File-&gt;Other-&gt;Maven-&gt;Maven Project-&gt;Next<br><img src="https://upload-images.jianshu.io/upload_images/3110861-a8acd19bfa85dbea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图15.png"><br>II. 勾选Use default Workspace location是将工程创建在默认的路径下<br><img src="https://upload-images.jianshu.io/upload_images/3110861-6d9891840f2239bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图16.png"><br>III. 点击最后一项-&gt;Next<br><img src="https://upload-images.jianshu.io/upload_images/3110861-5a5efe93b6aaf592.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图17.png"></p>
<ul>
<li>maven-archetype-quickstart: 普通Java工程</li>
<li>maven-archetype-webapp: Web工程<br>IV. 配置信息-&gt;点击Finish.<br><img src="https://upload-images.jianshu.io/upload_images/3110861-6b4b9177ba6366c6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图18.png"></li>
<li>Group Id：项目的名称，项目名称以域名的倒序命名(类似java包名)，比如我们要创建一个CRM的项目，可写为cn.itcast.crm。</li>
<li>Artifact Id：模块名称（子项目名称）。</li>
<li>Version：项目当中模块的版本，snapshot（快照版或测试版，没有正式发行）、release（正式发行版本）。</li>
<li>Package：包名。Group Id + Artifact Id.<br>V. 解决错误<br><img src="https://upload-images.jianshu.io/upload_images/3110861-5e132867e47beb1f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图19.png"><br><strong>错误原因：</strong>未Server Runtime.<br><strong>解决办法：</strong>邮件项目-&gt;Build Path-&gt;Configure Build Path…-&gt;Libraries-&gt;Add Library…-&gt;Next-&gt;apply..<br><img src="https://upload-images.jianshu.io/upload_images/3110861-90e40a33c495d6e0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图20.png"><br><img src="https://upload-images.jianshu.io/upload_images/3110861-56016aa23acfdcb4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图21.png"><br>VI. 项目结构<br><img src="https://upload-images.jianshu.io/upload_images/3110861-2beb14f0ebc82bc6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图21.png"><br><strong>*注意：新创建的maven工程的目录结构不是一个完整的目录结构。</strong><br>maven工程的一个完整的目录结构为：<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">project</span><br><span class="line">    /src/main/java       主体程序的java源文件（不要放配置文件）</span><br><span class="line">    /src/main/resources  主体程序所需要的配置文件（不要放java文件）</span><br><span class="line">    /src/test/java       单元测试程序的java源文件</span><br><span class="line">    /src/test/resources  单元测试程序所用的配置文件</span><br><span class="line">    /target              编译输出目录</span><br><span class="line">    /pom.xml</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>######2). 配置<br>I. 设置maven的编译版本，由于我使用的是JDK1.8，所以要设置maven的编译版本为1.8，即要在maven工程的pom.xml文件中添加如下配置：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span><br><span class="line">	xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;</span><br><span class="line">	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</span><br><span class="line">	&lt;groupId&gt;com.mazaiting.cmp&lt;/groupId&gt;</span><br><span class="line">	&lt;artifactId&gt;MavenTest&lt;/artifactId&gt;</span><br><span class="line">	&lt;packaging&gt;war&lt;/packaging&gt;</span><br><span class="line">	&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;</span><br><span class="line">	&lt;name&gt;MavenTest Maven Webapp&lt;/name&gt;</span><br><span class="line">	&lt;url&gt;http://maven.apache.org&lt;/url&gt;</span><br><span class="line">	&lt;dependencies&gt;</span><br><span class="line">		&lt;dependency&gt;</span><br><span class="line">			&lt;groupId&gt;junit&lt;/groupId&gt;</span><br><span class="line">			&lt;artifactId&gt;junit&lt;/artifactId&gt;</span><br><span class="line">			&lt;version&gt;3.8.1&lt;/version&gt;</span><br><span class="line">			&lt;scope&gt;test&lt;/scope&gt;</span><br><span class="line">		&lt;/dependency&gt;</span><br><span class="line">	&lt;/dependencies&gt;</span><br><span class="line">	&lt;build&gt;</span><br><span class="line">		&lt;finalName&gt;MavenTest&lt;/finalName&gt;</span><br><span class="line">		&lt;plugins&gt;</span><br><span class="line">			&lt;plugin&gt;</span><br><span class="line">				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;</span><br><span class="line">				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;</span><br><span class="line">				&lt;configuration&gt;</span><br><span class="line">					&lt;source&gt;1.8&lt;/source&gt;</span><br><span class="line">					&lt;target&gt;1.8&lt;/target&gt;</span><br><span class="line">					&lt;encoding&gt;UTF-8&lt;/encoding&gt;</span><br><span class="line">				&lt;/configuration&gt;</span><br><span class="line">			&lt;/plugin&gt;</span><br><span class="line">		&lt;/plugins&gt;</span><br><span class="line">	&lt;/build&gt;</span><br><span class="line">&lt;/project&gt;</span><br></pre></td></tr></table></figure></p>
<p>maven运行的时候都是依赖于插件的，包括编译也是需要通过插件——org.apache.maven.plugins(该插件就在你的本地仓库)来完成。<br>II. 添加完如上配置之后，可发现我们的maven工程上面有一个红叉，如下所示：<br><img src="https://upload-images.jianshu.io/upload_images/3110861-f4b135ef07df8617.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图22.png"></p>
<p>III. 更新项目。右键项目-&gt;Maven-&gt;Update Project…<br><img src="https://upload-images.jianshu.io/upload_images/3110861-fab394448fd754ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图23.png"></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/08/06/Mac/Mac电脑使用设置/" rel="next" title="Mac电脑使用设置">
                <i class="fa fa-chevron-left"></i> Mac电脑使用设置
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/08/06/MySQL/MySQL-基础---事务/" rel="prev" title="MySQL-基础---事务">
                MySQL-基础---事务 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blog/images/avatar.jpeg"
                alt="凌浩雨" />
            
              <p class="site-author-name" itemprop="name">凌浩雨</p>
              <p class="site-description motion-element" itemprop="description">专业从事于移动端开发，Android与iOS均有涉及，主做Android开发与React Native开发</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">393</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">凌浩雨</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
